<template>
  <div class="app-container">
    <!-- 添加或修改会员管理对话框 -->
    <el-dialog title="提现记录" :visible.sync="visible" width="50%" append-to-body :close-on-click-modal="false" @close="dialogClose">
      <el-row style="margin-bottom: 10px">
        <el-col :span="12">用户ID：{{ userId }}</el-col>
        <el-col :span="12">用户名称： {{ userName }}</el-col>
      </el-row>
      <el-table v-loading="loading" :data="tenantList">
        <el-table-column label="编号" align="center" prop="id" sortable />
        <el-table-column label="提现金额(元)" align="center" width="120" prop="money" sortable>
          <template slot-scope="scope">
            <span>￥{{ scope.row.money }}</span>
          </template>
        </el-table-column>
        <el-table-column label="提现渠道" align="center" width="120" prop="withdrawType">
          <template slot-scope="scope">
            <span>{{ scope.row.withdrawType === 1 ? '支付宝' : '微信'}}</span>
          </template>
        </el-table-column>
        <el-table-column label="提现状态" align="center" width="120" prop="checkStatus">
          <template slot-scope="scope">
            <span>{{ scope.row.checkStatus === 0 ? '待审核' : scope.row.checkStatus === 1 ? '审核成功' : '审核失败' }}</span>
          </template>
        </el-table-column>
        <el-table-column label="申请时间" align="center" width="120" prop="createTime" sortable>
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createTime) }}</span>
          </template>
        </el-table-column>
      </el-table>

      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getList" />

      <div slot="footer" class="dialog-footer">
        <el-button size="mini" @click="dialogClose">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>
  
<script>
import { getExtendWithdrawRecord } from "@/api/shuiyin/shuiyin";

export default {
  props: {
    userId: {
      type: String,
      default: ''
    },
    userName: {
      type: String,
      default: ''
    },
    dialogVisibleFlag: {
      default: false
    }
  },
  data() {
    return {
      visible: false,
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 租户管理表格数据
      tenantList: [], 
      // 查询参数
      queryParams: {
        userId: null,
        pageNum: 1,
        pageSize: 10,
      }
    };
  },
  watch: {
    dialogVisibleFlag() {
      this.visible = this.dialogVisibleFlag;
      if (this.visible) {
        this.getList();
      }
    }
  },
  methods: {
    dialogClose() {
      this.$emit("update:dialogVisibleFlag", false)
    },
    /** 查询租户管理列表 */
    getList() {
      this.queryParams.userId = this.userId;
      this.loading = true;
      getExtendWithdrawRecord(this.queryParams).then(response => {
        this.tenantList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
  }
};
</script>